<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title> <?php echo $top['subject'] ? $top['subject'] : '输错了吧？'?> - <?=SITE_NAME?> </title>
<?php include VIEWS.'header.html'?>

<?php if($code['forum'] == 1):?><script type="text/javascript">location.href='/forum/<?php echo $data['id']?>/'</script><?php endif?>

<style type="text/css">
b.master {
    color: #FF6240;
    padding: 2px;
}

b.guest {
    color: #CCC;
    padding: 2px;
}

b.default {
    color: #666;
    padding: 2px;
}
</style>

<script type="text/javascript">
<!--
var aa = ajaxStart();
var timer = null;

function newReply() {
    var f = $('replyform');
    $('submit').disabled = true;

    $('updatemsg').hide(); $('loading').show();
    
    try {
        aa.call('/forum.php/<?php echo $data['id']?>/<?php echo $data['tid']?>', 'ajaxNewReply', newReply_result, $('replyform').serialize());
        return false;
    } catch (e) {
        return true;
    }
}

function newReply_result(result) {
    var i;
    var d = $('updatemsg');
    var err = 0;
    var ok = 0;
    
    $('loading').hide();

    try {
        var stat = result.result[0].data;
        switch(stat) {
            case 32:
                i = '请检查您的Email是否正确';err = 1;$('umail').focus();break;
            case 16:
                i = '姓名不能为空哦';err = 1;$('uname').focus();break;
            case 8:
                i = '您想说什么';err = 1;$('body').focus();break;
            case 4:
                i = '请不要重复发布相同内容，谢谢';err = 1;$('body').focus();break;
            case 1:
                var node = result.fdata[0];
                var newhtml = '<hr size="1" /><b>'+ node.uname[0].data +'<\/b>';
                newhtml += ' &nbsp; 在&nbsp; '+ node.updated[0].data +' 回应：<br />';
                newhtml += node.body[0].data;
                $('toplist').innerHTML += newhtml;
                ok = 1;
                $('body').focus();
                $('body').value = '';
                break;
            default:
                err = 1;i = '未知错误('+stat+')，请稍候再试';
        }
    } catch(e) {
        i = '服务器错误，请稍候再试';
        err = 1;
    }

    $('submit').disabled = false;
    if (i) {
        if (err==1) {
            d.style.backgroundColor= '#FF6600';
            d.style.color= '#FFF';
        } else {
            d.style.backgroundColor= '#DDF63E';
            d.style.color= '#000';
        }
        d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
        $('updatemsg').show();
        new Effect.Round('div', 'updatemsg');
        if (timer) window.clearTimeout(timer);
        timer = setTimeout( "$('updatemsg').style.display='none';", 10000);
    }
    if (ok) $('updatemsg').style.display='none';
}
//-->
</script>

</head>

<body>
<?php include VIEWS.'topbar.html'?>

<div id="content">

    <?php include VIEWS.'leftnav.html'?>

    <div id="right">

<?php if($code['forum'] == 4):?>
    <h1>输错了吧?</h1>
    <div class="errbox roundNormal">&nbsp;&nbsp;&nbsp;是不是输入错了？</div>
    <?php else:?>
    <div style="float:right"><a href="/forum/<?php echo $data['id']?>">返回列表</a>&nbsp;&nbsp;</div>
    <h1> <?php echo $top['subject']?> </h1>
    <hr size="1">
    <div id="topitem" style="line-height:180%;font-size:12px;margin-left:2em">
        <img width="32" height="32" src="http://www.gravatar.com/avatar.php?gravatar_id=<?=md5(strtolower($top['umail']))?>&amp;size=32&amp;default=<?php echo $_servername?>/images/icon/no-gravatar.gif" align="left" hspace="5" />
        <?php echo '<b class="'. ($v['isadmin'] ? 'master' : ($v['uid'] ? 'default' : 'guest')) .'">'.($top['uname'] ? $top['uname'] : 'guest').'</b> &nbsp; 在&nbsp; '.date('Y-m-d H:i:s', $top['created'])?> 写道：
        <?php if($session['admin']):?>(<?php echo $top['umail']?>) (<a href="/forum/<?php echo $data['id']?>?remove=<?php echo $data['tid']?>" onclick="javascript:return confirm('请确认全部删除！')">删除所有回复</a>)<?php endif?><br />
        <div style="margin-left:20px;margin-top:10px;font-size:14px"><?php echo nl2br($top['body'])?></div>
    </div>

    <div id="toplist" style="line-height:180%;font-size:12px;margin-left:100px">
    <?php foreach ($list as $v):?>
        <hr size="1">
        <img width="32" height="32" src="http://www.gravatar.com/avatar.php?gravatar_id=<?=md5(strtolower($v['umail']))?>&amp;size=32&amp;default=<?php echo $_servername?>/images/icon/no-gravatar.gif" align="left" hspace="5" />
        <?php echo '<b class="'. ($v['isadmin'] ? 'master' : ($v['uid'] ? 'default' : 'guest')) .'">'.($v['uname'] ? $v['uname'] : 'guest').'</b> &nbsp; 在&nbsp; '.date('Y-m-d H:i:s', $v['updated'])?> 回应：<?php if($session['admin']):?>(<?php echo $v['umail']?>) (<a onclick="javascript:return confirm('请确认删除！')" href="?remove=<?php echo $v['id']?>">删除本回复</a>)<?php endif?><br />
        <?php echo nl2br($v['body'])?>
    <?php endforeach?>
    </div>

    <div id="newpost" style="text-align:left;margin:0 0 0 100px">
    <hr size="1">
    <div id="loading" style="display:none;"><img src="/images/icon_indicator.gif" width="220" height="19" alt=""  /></div>
    <div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#DDF63E;font-size:12px;width:100%;display:none;">&nbsp;</div><br clear="all">
    <?php if($code['newReply']==8):?><div class="errbox roundNormal" style="width:80%">&nbsp;&nbsp;不写内容可不行啊！</div><br clear="all" /><?php endif?>
    <?php if($code['newReply']==16):?><div class="errbox roundNormal" style="width:80%">&nbsp;&nbsp;请输入您的姓名！</div><br clear="all" /><?php endif?>
    <?php if($code['newReply']==32):?><div class="errbox roundNormal" style="width:80%">&nbsp;&nbsp;请输入正确的Email！</div><br clear="all" /><?php endif?>
    <form action="/forum.php" method="post" id="replyform" onsubmit="javascript:return newReply();">
    <textarea id="body" name="body" rows="10" cols="60"><?php echo $data['body']?></textarea><br />
    <?php if(!$session['login']):?>姓名：<input class="input0" value="<?php echo $data['uname']?>" id="uname" size="10" maxlength="20" type="text" name="uname"> &nbsp; Email：<input class="input0" value="<?php echo $data['umail']?>" id="umail" size="10" maxlength="60" type="text" name="umail"> &nbsp; <a class="px12" href="/login?from=<?php echo urlencode("/forum/{$data['id']}/{$data['tid']}")?>">会员请登录</a><br /><?php endif?>
    <br />
    <input accesskey="s" id="submit" type="submit" name="Submit" value="发表我的回应" class="bluebtn">
    </form>
    </div>

<?php endif?>
    </div>
</div>

<?php include VIEWS.'copyright.html'?>

</body>
</html>
